package com.lid.labelview.slice;

import com.lid.labelview.ResourceTable;
import com.lid.lib.LabelButtonView;
import com.lid.lib.LabelImageView;
import com.lid.lib.LabelTextView;

import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Component;

/**
 * MainAbilitySlice;
 *
 * @since 2021-04-13
 */
public class MainAbilitySlice extends AbilitySlice {
    private static final int DISTANCE = 40;
    private static final int ORIENTATION = 3;

    /**
     * onStart
     *
     * @param intent
     */
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_main);

        LabelButtonView labelButtonView = (LabelButtonView) findComponentById(ResourceTable.Id_labelbutton);
        labelButtonView.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                labelButtonView.setLabelVisual(!labelButtonView.isLabelVisual());
            }
        });

        LabelImageView labelImageView1 = (LabelImageView) findComponentById(ResourceTable.Id_image1);
        labelImageView1.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                labelImageView1.setLabelDistance(DISTANCE);
            }
        });

        LabelImageView labelImageView2 = (LabelImageView) findComponentById(ResourceTable.Id_image2);
        labelImageView2.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                labelImageView2.setLabelText("ART");
            }
        });

        LabelTextView labelTextView = (LabelTextView) findComponentById(ResourceTable.Id_text);
        labelTextView.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                labelTextView.setLabelOrientation(ORIENTATION);
            }
        });

        findComponentById(ResourceTable.Id_click).setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                present(new ListViewActivity(),new Intent());
            }
        });

        findComponentById(ResourceTable.Id_click11).setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                present(new RecyclerViewActivity(),new Intent());
            }
        });
    }

    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}
